//
//  BRCrossingCollectionViewController.m
//  百思不得姐
//
//  Created by LinBrong on 16/8/26.
//  Copyright © 2016年 LinBrong. All rights reserved.

/*穿越:
 全部:http://d.api.budejie.com/topic/list/chuanyue/1/bs0315-iphone-4.3/0-20.json
 视频:http://d.api.budejie.com/topic/list/chuanyue/41/bs0315-iphone-4.3/0-20.json
 图片:http://d.api.budejie.com/topic/list/chuanyue/10/bs0315-iphone-4.3/0-20.json
 段子:http://d.api.budejie.com/topic/list/chuanyue/29/bs0315-iphone-4.3/0-20.json
 声音:http://d.api.budejie.com/topic/list/chuanyue/31/bs0315-iphone-4.3/0-20.json*/
//
//http://d.api.budejie.com/topic/list/chuanyue/1/bs0315-iphone-4.3/0-20.json
#define kURLStr @[@"topic/list/chuanyue/1/bs0315-iphone-4.3/0-20.json",@"topic/list/chuanyue/41/bs0315-iphone-4.3/0-20.json",@"topic/list/chuanyue/10/bs0315-iphone-4.3/0-20.json",@"topic/list/chuanyue/29/bs0315-iphone-4.3/0-20.json",@"topic/list/chuanyue/31/bs0315-iphone-4.3/0-20.json"]

#import "BRCrossingCollectionViewController.h"
#import "BRCrossingTableViewController.h"
#import "BRCrossingCollectionViewCell.h"

@interface BRCrossingCollectionViewController ()


/*    */
@property (strong, nonatomic) NSMutableDictionary *cellDict;


@end

@implementation BRCrossingCollectionViewController

static NSString * const reuseIdentifier = @"Cell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _cellDict = [NSMutableDictionary dictionary];
    
    self.collectionView.pagingEnabled = YES;
   

    [self.collectionView registerClass:[BRCrossingCollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier];
    
}



#pragma mark <UICollectionViewDataSource>
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    //    return self.dataArr.count;
    return 5;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    BRCrossingCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath];
  
    
    cell.URLStr = kURLStr[indexPath.item];
//    
//    if([self.cellDict valueForKey:[NSString stringWithFormat:@"%zd",indexPath.item]] == nil){
//        
//        [self.cellDict setValue:cell forKey:[NSString stringWithFormat:@"%zd",indexPath.item]];
//        
//    }else {
//
//    
//        cell = [self.cellDict valueForKey:[NSString stringWithFormat:@"%zd",indexPath.item]];
//    }
    
    cell.tag = indexPath.item;
    return cell;
}




-(instancetype)init {
    
    
    //设置layout
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    layout.minimumLineSpacing = 0.0;
    layout.minimumInteritemSpacing = 0.0;
    layout.itemSize = CGSizeMake([UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height - 108);
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    
    return [self initWithCollectionViewLayout:layout];
    
    
}

//刷新数据
-(void)downloadDataWith:(NSInteger)index {
    
//    NSString *urlStr = nil;
//    switch (index) {
//        case 0:
//            urlStr = @"api_open.php?a=list&c=data&order=timewarp";
//            break;
//        case 1:
//            urlStr = @"api_open.php?a=list&c=data&order=timewarp";
//            break;
//        case 2:
//            urlStr = @"api_open.php?a=list&c=data&order=timewarp";
//            break;
//        case 3:
//            urlStr = @"api_open.php?a=list&c=data&order=timewarp";
//            break;
//        case 4:
//            urlStr = @"api_open.php?a=list&c=data&order=timewarp";
//            break;
//            
//        default:
//            break;
//    }
//    
    
//    [BRCrossingModel downloadWithURLStr:urlStr successBlock:^(NSArray *Array) {
//        //        [self.dataArr addObjectsFromArray:Array];
//        
//        //        NSLog(@"-+-%@",self.dataArr);
//        //        [self.tableView reloadData];
//        //        [self creatTableView];
//        
//        //现在先加在后面.等等再做判断
//        self.dataArr[index] = Array;
//        
//        self.collectionVc.dataArr = self.dataArr;
//        
//        
//    } failBlock:^(NSError *error) {
//        NSLog(@"%@",error);
//    }];
//    
//    //    NSLog(@"---%@",_dataArr);
}

@end
